//
//  SDAnswersTestReportData.m
//
//  Created by   on 2019/3/12
//  Copyright (c) 2019 __MyCompanyName__. All rights reserved.
//

#import "SDAnswersTestReportData.h"


NSString *const kSDAnswersTestReportDataId = @"id";
NSString *const kSDAnswersTestReportDataCreateTime = @"createTime";


@interface SDAnswersTestReportData ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation SDAnswersTestReportData

@synthesize id = _id;
@synthesize createTime = _createTime;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict {
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if (self && [dict isKindOfClass:[NSDictionary class]]) {
            self.id = [self objectOrNilForKey:kSDAnswersTestReportDataId fromDictionary:dict];
            self.createTime = [self objectOrNilForKey:kSDAnswersTestReportDataCreateTime fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.id forKey:kSDAnswersTestReportDataId];
    [mutableDict setValue:self.createTime forKey:kSDAnswersTestReportDataCreateTime];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description  {
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];

    self.id = [aDecoder decodeObjectForKey:kSDAnswersTestReportDataId];
    self.createTime = [aDecoder decodeObjectForKey:kSDAnswersTestReportDataCreateTime];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_id forKey:kSDAnswersTestReportDataId];
    [aCoder encodeObject:_createTime forKey:kSDAnswersTestReportDataCreateTime];
}

- (id)copyWithZone:(NSZone *)zone {
    SDAnswersTestReportData *copy = [[SDAnswersTestReportData alloc] init];
    
    
    
    if (copy) {

        copy.id = [self.id copyWithZone:zone];
        copy.createTime = [self.createTime copyWithZone:zone];
    }
    
    return copy;
}


@end
